/*
 * Instruction32.java
 *
 * Created on March 21, 2007, 10:37 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
/*
Accumulator A is loaded from the address indicated by the stack pointer.
The SP is then incremented by one.
Pull instructions are commonly used at the end of a subroutine, to
restore the contents of CPU registers that were pushed onto the stack
before subroutine execution.
 */
package moto9s12sim;

/**
 *
 * @author Fergus Earnshaw
 */
public class Instruction32 extends Instruction{
    
    /** Creates a new instance of Instruction32 */
    public Instruction32() {
       this.strAssemblyCode = "PULA";
        this.bCodes = new byte[1];
        this.bCodes[0] = (byte)Integer.parseInt("32",16);
    }
    
    public boolean excute(M9S12 cpu)
    {
        this.shAddr = cpu.PC.getRegister();
        cpu.PC.inc();
        
        //(M(SP)) => A
        //(SP) + $0001 => SP
        cpu.A.setRegister(cpu.bMemory[cpu.SP.getUnsignedRegister()]);
        cpu.SP.inc();
        
        printInstruction(cpu);
        //I think the first invalid instruction should halt excution
        return true;
    }    
}
